package com.liu.lab05.filter;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;
import java.io.IOException;
import java.io.PrintWriter;

//@WebFilter("/*")
public class FirstFilter implements Filter {
	public void destroy() {
		System.out.println("First------destroy");
	}
	public void doFilter(ServletRequest request, ServletResponse response,
						 FilterChain chain) throws IOException, ServletException {
		//设置响应类型
		response.setContentType("text/html;charset=utf-8");
		//获得输出对象out
		PrintWriter out=response.getWriter();
		//在浏览器中输出
		out.print("执行过滤器FirstFilter<br>");
		//执行下一个过滤器
		chain.doFilter(request, response);
	}

	public void init(FilterConfig fConfig) throws ServletException {
		System.out.println("First------init");
	}
}
